package com.wwg;

import java.util.ArrayList;
import java.util.List;

/**
 * 车模型
 */

public abstract class CarModel {

    private List<String> sequence = new ArrayList<>();//步骤集合

    protected abstract void start();
    protected abstract void stop();
    protected abstract void alarm();
    protected abstract void engineBoom();

    /**
     * 开车
     */
    public final void run(){

        for(int i=0; i<sequence.size(); i++){

            String actionName = sequence.get(i);

            if(actionName.equals("start")){
                this.start();
            }else if (actionName.equals("stop")){
                this.stop();
            }else if (actionName.equals("alarm")){
                this.alarm();
            }else if (actionName.equals("engineBoom")){
                this.engineBoom();
            }else {
                System.out.println("input text is error");
            }

        }
    }

    public final void setSequence(List<String> sequence){
        this.sequence = sequence;
    }

}
